package com.hspedu.newData.dmsxl.动态规划.跳跃游戏;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-27 
 * @Version: 1.0
 */

// todo
public class LC55跳跃游戏 {

    public boolean canJump(int[] nums) {

        if (nums.length < 2) return true;

        int[] dp = new int[nums.length];
        dp[0] = nums[0];

        for (int i = 1; i < nums.length; i++) {
            dp[i] = Math.max(dp[i-1],i + nums[i-1]);
            if (dp[i] < i + 1){
                return false;
            }
        }
        return dp[nums.length - 1] >= nums.length;
    }
}
